#include <iostream>
#include "spot.h"
#include "table_output.h"
using namespace std;

const char *enum_spot_str[] =
    {"未指定" ,"云谷寺", "白鹅岭", "白鹅新站","石笋崖","始信峰","北海宾馆狮林大酒店","猴子观海","松谷庵站","大王松","排云楼宾馆排云亭西海饭店","丹霞峰","丹霞站","排云溪站","天海站","白云宾馆","光明顶","迎客松","天都峰","新道口","慈光阁","玉屏索道上站","步仙桥","吊桥庵"};//感谢同学辛苦帮我补完~

void showSpots(spot spotarr[], int num){//真该死，我怎么忘了way里还有一个长度为maxjumps的spot数组,girr~
    //cout<<"sfd"<<endl;//good
    int len=0;
    if(!num){
        cout<<"  []"<<endl;
        return;
    }
    int count=0;//小插曲，最开始忘记显示赋值，结果又一次它居然默认是2.。。。。
    cout<<"[";



    //cout<<"sfd"<<endl;//still good

    while(count<=num-1){
        //cout<<"wyc"<<endl;
        cout<<enum_spot_str[spotarr[count]]<<",";
        //cout<<"wrq"<<endl;//未指定什么时候有4个步数了
        count++;
    }
    cout<<"\b]"<<endl;
    return;
};

void showWays(Way wayarr[]){
    TextTable table( '-', '|', '+' );
    /*
    很遗憾，表格输出库都找好了并且加进来了，
    但是忘记路径是动态数组了，
    我真的非常不想和动态堆内存再做斗争将其转化为字符串
    但是既然已经都找好了就姑且浪费一点内存和编译时间吧
    再次证明了应当能省则省
    */
    int count=0;
    cout<<"目标    步数  代价  路径"<<endl;
    while(count<=total){
        //cout.width(2);
        cout<<enum_spot_str[count];
        cout.width(6);
        cout<<wayarr[count].steps;
        cout.width(5);
        cout<<wayarr[count].cost;//到这都还好了，意思是子函数问题
        cout.width(5);
        //cout<<endl;//我侧，咋又成空指针了我去
        showSpots(wayarr[count].path,wayarr[count].steps);
        count++;
    }
};